<template>
    <view class="content">
        <view class="title text-lg">养护计划</view>
        <view class="box">
            <view class="item">
                <view>计划名称</view>
                <view class="item-r">
                    <input type="text" v-model="name" placeholder="请输入" class="inp">
                </view>
            </view>
            <view class="item">
                <view>养护类型</view>
                <view class="item-r" @click="open(1)">
                    <input type="text" v-model="conserve" placeholder="请选择" class="inp" disabled>
                    <u-icon name="arrow-down-fill" color="#a7a7a7" size="28" class="u-m-l-15"></u-icon>
                </view>
            </view>
            <view class="item">
                <view>计划时间</view>
                <view class="item-r" @click="open(2)">
                    <input type="text" v-model="planTime" placeholder="请选择" class="inp" disabled>
                    <u-icon name="arrow-down-fill" color="#a7a7a7" size="28" class="u-m-l-15"></u-icon>
                </view>
            </view>
        </view>
        
        <view class="btn-square u-m-30" @click="$noMultipleClicks(doSubmit)">确认</view>
        
        <!-- 选择时间 -->
        <u-picker v-model="JHtimeShow" mode="time" :params="timeParams" @confirm="chooseTime(3, $event)"></u-picker>
        <!-- 养护类型 -->
        <u-select v-model="show" mode="single-column" :list="conserveList" value-name="id" label-name="name" @confirm="confirm"></u-select>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                noClick: true,//连点
                JHtimeShow: false, //计划时间
                planTime: '', //计划时间
                timeParams: { //时间格式
                	year: true,
                	month: true,
                	day: true,
                	hour: false,
                	minute: false,
                	second: false
                },
                name: '',
                show: false,
                conserveList: [{id:0, name: '一般养护'},{id:1, name: '重点养护'}],
                conserve: '',
                conserveId: '',
            };
        },
        onLoad(option) {
            
        },
        methods: {
            doSubmit() {
                if (!this.name) {
                    this.$toast('请输入计划名称')
                    return
                }
                if (!this.conserve) {
                    this.$toast('请选择养护类型')
                    return
                }
                if (!this.planTime) {
                    this.$toast('请选择计划时间')
                    return
                }
                this.$ajax('inventorys/add_nurture_plan', {
                    userToken: this.$getSync('userToken'),
                    name: this.name,
                    type: this.conserveId,// 养护类型 0-一般养护 1-重点养护
                    plan_time: this.planTime,//计划养护时间
                }).then(ret => {
                	if (ret.status == 0) {
                        this.$toast('提交成功');
                        setTimeout(() => {
                            this.$backT()
                        }, 500)
                	} else {
                		this.$toast(ret.message);
                	}
                });
            },
            
            open(num) {
                if (num == 1) {
                    this.show = true
                } else if (num == 2) {
                    this.JHtimeShow = true
                }
            },
            
            //选择时间
            chooseTime(num, e) {
                if (num == 3) {
                    this.planTime = e.year + '-' + e.month + '-' + e.day;
                }
            },
            
            // 选择养护类型
            confirm(e) {
                console.log(e);
                this.conserve = e[0].label
                this.conserveId = e[0].value
            },
            
        }
    };
</script>

<style lang="scss">
    .t-inp2{
        width: 100%;
        min-height: 100rpx;
        height: auto;
        background-color: #f5f5f5;
        border-radius: 10rpx;
        padding: 15rpx;
        margin-top: 10rpx;
        color: #000;
    }
    .drug-btn{
        color: #fff;
        padding: 10rpx 40rpx;
        background-color: #8392a5;
        border-radius: 8rpx;
        margin-left: 20rpx;
    }
    
    page{
        background-color: #f5f5f5 !important;
    }
    .title{
        font-weight: bold;
        padding: 45rpx 50rpx 25rpx;
        position: relative;
    }
    .title::after{
        display: block;
        content: '';
        width: 8rpx;
        height: 26rpx;
        background-color: #ff4800;
        position: absolute;
        left: 25rpx;
        bottom: 32rpx;
    }
    
    
    .box{
        padding: 0 20rpx;
        background-color: #fff;
        border-radius: 15rpx;
        margin: 0 30rpx;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30rpx 0;
        border-bottom: 2rpx solid #e6e6e6;
    }
    .item:last-child{
        border-bottom: none;
    }
    .item-r{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
        text-align: right;
        padding-left: 20rpx;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }
    .item-img{
        padding: 30rpx 0;
    }
    .img{
        width: 316rpx;
        height: 200rpx;
        border-radius: 10rpx;
        margin-top: 20rpx;
    }
    
    
    .drug{
        background-color: #fff;
        border-radius: 15rpx;
        padding: 35rpx 30rpx;
        margin-bottom: 25rpx;
        word-break: break-all;
        white-space: pre-line;
    }
    .drug:last-child{
        margin-bottom: 0;
    }
    .drug-state1{
        font-size: 24rpx;
        color: #0075ff;
        padding: 9rpx 12rpx;
        background-color: #ebf4fe;
        border-radius: 8rpx;
        margin-left: 20rpx;
    }
    
    
    .examine{
        word-break: break-all;
        white-space: pre-line;
        padding: 15rpx 25rpx 30rpx;
        background-color: #fff;
        border-radius: 15rpx;
        margin: 0 30rpx 25rpx;
    }
    .t-inp{
        width: 100%;
        min-height: 150rpx;
        height: auto;
        padding-top: 15rpx;
    }
    .examine2{
        padding: 15rpx 0;
    }
    .img-box{
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }
    .up-photo{
        width: 187rpx;
        height: 187rpx;
        margin-right: 15rpx;
        margin-top: 15rpx;
    }
    
    
    .btns{
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 30rpx;
    }
    .refuse-btn{
        font-size: 34rpx;
        color: #757575;
        padding: 25rpx 130rpx;
        background-color: #fff;
        border: 2rpx solid #d8d8d8;
        border-radius: 10rpx;
    }
    .take-btn{
        font-size: 34rpx;
        color: #fff;
        padding: 25rpx 130rpx;
        background-color: #ff4800;
        border-radius: 10rpx;
        margin-left: 20rpx;
    }
    
    .enter-btn{
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding-top: 10rpx;
    }
    .enter-btn>view{
        padding: 15rpx 50rpx;
        background-color: #8392a5;
        border-radius: 10rpx;
        color: #fff;
    }
    
    .place{
        word-break: break-all;
        white-space: pre-line;
        padding: 5rpx 20rpx 20rpx;
        background-color: #f5f6f8;
        border-radius: 10rpx;
        margin-top: 30rpx;
    }
    .wrapper{
        padding: 0 30rpx;
    }
    .choose-01{
        width: 33rpx;
        height: 33rpx;
        margin-right: 15rpx;
    }
    .time-02{
        width: 33rpx;
        height: 34rpx;
        margin-left: 15rpx;
    }

</style>
